package com.yksj.healthtalk.utils;

import android.content.Context;

import com.yksj.healthtalk.entity.CustomerInfoEntity;
import com.yksj.healthtalk.net.socket.SmartControlClient;
import com.yksj.healthtalk.net.socket.SmartFoxClient;
import com.yksj.healthtalk.ui.app.AppData;
import com.yksj.healthtalk.ui.app.HTalkApplication;

public class CustomerInfoUtil {

	/**
	 * 判断客户资料是否填写完全
	 * @return boolean 填写完全true
	 */
	public static boolean isCustomerInfoFull(AppData appData){
		CustomerInfoEntity customerInfoEntity = (CustomerInfoEntity)
		appData.getCustomerInfoEntity(SmartControlClient.getControlClient().getUserId());
		if(customerInfoEntity == null)return false;
		//昵称 ，性别和头像未填写
		if(customerInfoEntity.getUsername() == null||customerInfoEntity.getUsername().equals("") ||"Z".equalsIgnoreCase(customerInfoEntity.getSex()) || customerInfoEntity.getNormalHeadIcon().startsWith("assets/customerIcons")||"".equals(customerInfoEntity.getNormalHeadIcon())){
			return false;
		}
		return true;
	}
	
	/**
	 * 
	 * 添加客户资料到缓存
	 * @param infoEntity
	 * @param userId
	 */
	public static void addCustomerInfoToCache(CustomerInfoEntity infoEntity,String userId,AppData appData){
		CustomerInfoEntity customerInfoEntity = (CustomerInfoEntity)appData.getCustomerInfoEntity(userId);
		if(customerInfoEntity == null){
			appData.updateCacheInfomation(infoEntity);
		}
	}
	
	/**
	 *  获得当前登录的客户资料
	 * @return
	 */
	public static CustomerInfoEntity getCurrentLoginCustomerInfo(AppData appData){
		return getCustomerInfoById(SmartFoxClient.getSmartFoxClient().getUserId(),appData);
	}
	
	/**
	 * 获取当前登录的客户资料
	 */
	public static CustomerInfoEntity getLoginUserCustomerInfo(Context context){
		AppData appData = HTalkApplication.getAppData();
		return getCustomerInfoById(SmartFoxClient.getSmartFoxClient().getUserId(),appData);
	}
	/**
	 * 
	 * 根据id获取客户资料
	 * @param cusId
	 * @return CustomerInfoEntity 客户资料
	 */
	public static CustomerInfoEntity getCustomerInfoById(String cusId,AppData appData){
		CustomerInfoEntity customerInfoEntity = (CustomerInfoEntity)appData.getCustomerInfoEntity(cusId);
		return customerInfoEntity;
	}
}
